<?php
require_once FW_DIR_FRAMEWORK_VENDOR.DS.'thumb'.DS.'ThumbLib.inc.php';

/**
 * 유틸리티 - Thumbnail
 *
 * @package    util
 *
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 *
 * @author jylee3@simplexi.com
 * @version    1.0
 */
class utilThumb extends GdThumb
{
    /**
     * Thumnail Generator
     *
     * <code>
     * $utilThumb = utilThumb::getInstance($sSourceFileName);
     *
     * or
     *
     * $utilThumb = utilThumb::getInstance($sSourceFileName, array('jpegQuality'=>30));
     *
     * or
     *
     * $utilThumb = utilThumb::getInstance($sSource, array(), true);
     *
     * $utilThumb->setOptions(array('jpegQuality'=>30));
     * $utilThumb->crop(10, 30, 500, 200)->save($sSourceFileName_Output, 'JPG');
     * </code>
     *
     * @param    String    $sSourceFileName
     * @param    Array    $aOptions
     *     'resizeUp'    => false,    // 이미지 확대 가능 여부
     *     'jpegQuality'    => 100,    // 이미지 퀄리티 설정(기본값:100)
     *     'correctPermissions'    => false,
     *     'preserveAlpha'    => true,
     *     'alphaMaskColor'    => array (255, 255, 255),
     *     'preserveTransparency'    => true,
     *     'transparencyMaskColor'    => array (0, 0, 0)
     * @param    Boolean    $isDataStream
     *
     * @return utilThumb
     */
    public static function getInstance($sSourceFileName, $aOptions=array(), $isDataStream=false)
    {
        $phpThumb = PhpThumb::getInstance();
        $phpThumb->loadPlugins((PhpThumbFactory::$pluginPath));
        $sRegistry = $phpThumb->getPluginRegistry(PhpThumbFactory::$defaultImplemenation);

        $utilThumb =  new self($sSourceFileName, $aOptions, $isDataStream);
        $utilThumb->importPlugins($sRegistry);

        return $utilThumb;
    }
}